package com.example.back.controller;

import com.example.back.dto.req.ZDrugDoDisableReq;
import com.example.back.dto.req.ZDrugListReq;
import com.example.back.dto.req.ZDrugSave;
import com.example.back.dto.resp.ZDrugInfoRsp;
import com.example.back.dto.resp.ZDrugListRsp;
import com.example.back.service.ZDrugService;
import com.example.common.support.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @Author wxy
 * @Date 2021/1/15 13:51
 * @Version 1.0
 */
@RestController
@Api(tags = "基础信息管理-中药管理")
@RequestMapping("/api/ZDrug")
public class ZDrugController {
    @Resource
    private ZDrugService zDrugService;

    @ApiOperation(value = "中药列表", notes = "中药列表")
    @PostMapping(value = "/List")
    public Result<PageInfo<ZDrugListRsp>> List(@RequestBody ZDrugListReq zDrugListReq) {
        return Result.success(zDrugService.List(zDrugListReq));
    }

    @ApiOperation(value = "启用、禁用", notes = "启用、禁用")
    @PostMapping(value = "/DoDisable")
    public Result<Object> DoDisable(@RequestBody ZDrugDoDisableReq zDrugDoDisableReq) {
        return Result.success(zDrugService.DoDisable(zDrugDoDisableReq));
    }

    @ApiOperation(value = "详情", notes = "详情")
    @PostMapping(value = "/Info")
    public Result<ZDrugInfoRsp> Info(@RequestBody ZDrugDoDisableReq zDrugDoDisableReq) {
        return Result.success(zDrugService.Info(zDrugDoDisableReq));
    }

    @ApiOperation(value = "上传文件", notes = "上传文件")
    @PostMapping(value = "/UpLoad")
    public Result<HashMap<String,Object>> UpLoad(@RequestParam(value = "file") MultipartFile file) {
        return Result.success(zDrugService.UpLoad(file));
    }

    @ApiOperation(value = "", notes = "")
    @PostMapping(value = "/Save")
    public Result<Object> Save(@RequestBody ZDrugSave zDrugSave) {
        return Result.success(zDrugService.Save(zDrugSave));
    }
}
